﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using ShevaEngine.Core.Modules.Graphics;
using ShevaEngine.Core.Modules.Graphics.Cameras;
using ShevaEngine.Core.Modules.Models;

namespace ShevaEngine.Core.Modules.Scenes
{
    /// <summary>
    /// Graphics scene object.
    /// </summary>
    public class GraphicsSceneObject : SceneObject
    {
        /// <summary>Sheva model.</summary>
        [ContentSerializerIgnore]
        public SceneNode RootNode;

        /// <summary>
        /// Constructor.
        /// </summary>
        public GraphicsSceneObject()
            : base()
        {
            this.RootNode = null;
        }        

        /// <summary>
        /// Constructor.
        /// </summary>
        public GraphicsSceneObject(SceneNode rootNode)
            : base()
        {
            this.RootNode = rootNode;
        }        

        /// <summary>
        /// Constructor.
        /// </summary>
        public GraphicsSceneObject(ShevaModel model, Matrix transformation)  
            : base(transformation)
        {            
            this.RootNode = model;            
        }        

        /// <summary>
        /// Override Add in rendering pipeline method.
        /// </summary>
        /// <param name="renderingPipeline"></param>
        public override void AddInRenderingPipeline(RenderingPipeline renderingPipeline, Camera camera)
        {
            if (this.RootNode != null)
                this.RootNode.AddInRenderingPipeline(renderingPipeline, camera, this.World);            
        }

        /// <summary>
        /// Add in rendering pipeline.
        /// </summary>
        /// <param name="renderinPipeline"></param>
        /// <param name="position"></param>
        /// <param name="distance"></param>
        public override void AddInRenderingPipeline(RenderingPipeline renderingPipeline, Vector3 position, float distance)
        {
            if (this.RootNode != null)
                this.RootNode.AddInRenderingPipeline(renderingPipeline, position, distance, this.World);            
        }        
    }
}
